/*
day89
2019.11.24
*/
#include<map>
#include<vector>
using namespace std;

struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
};


class Solution {
public:
	int help(struct TreeNode *root,map<int,int> &m)
	{
		if(!root) return 0;
		
		int left = help(root->left,m);
		int right = help(root->right,m);
		
		int sum = root->val + left + right;
		m[sum]++;
		
		return sum;
	}
	
    vector<int> findFrequentTreeSum(TreeNode* root) {
        map<int,int> m;
        vector<int> vec;
        help(root,m);
        int max=0;
        
        for(auto p=m.begin();p!=m.end();p++)
        {
        	if(p->second > max) max=p->second;
		}
		
		for(auto p=m.begin();p!=m.end();p++)
        {
        	if(p->second == max) vec.push_back(p->first);
		}
		return vec;

    }
};


int main()
{
	return 0;
}
